﻿//图标查询标准
var Pacm = Pacm || {};
Pacm.viewModel = Pacm.viewModel || {};

Pacm.viewModel.chart = function (data) {
    var self = this;
    this.idField = data.idField;
    this.urls = data.urls;
    this.resx = data.resx;
    this.dataSource = data.dataSource;
    this.form = ko.mapping.fromJS(data.form);
    delete this.form.__ko_mapping__;

    this.clearClick = function () {
        $.each(self.form, function () { this(''); });
        this.searchClick();
    };
    this.searchClick = function () {
        var param = ko.toJS(this.form);
        $.ajax({
            url: self.urls.query,
            data: param,
            success: function (d) {
                var val = d;
                var chart = new FusionCharts("../../../../Content/js/Charts/ZoomLine.swf", "ChartId", "100%", "100%", "0", "1", "FFFFFF", "exactFit");
                chart.setDataXML(val);
                chart.render("chartdiv");
            }
        });
    };
    this.refreshClick = function () {
        this.searchClick();
        //        var Ch = this.form.槽号(); //encodeURI(this.form.槽号());
        //        var Rq = this.form.日期();
        //        $.ajax({
        //            type: 'POST',
        //            url: "/Pacm/Scsj/GetChartSlotUIZoomLine",
        //            data: "{sCh:'" + Ch + "',sRq:'" + Rq + "'}",
        //            contentType: "application/json; charset=utf-8",
        //            datatype: "json",
        //            success: function (response) {
        //                var val = response;
        //                var chart = new FusionCharts("../../../../Content/js/Charts/ZoomLine.swf", "ChartId", "100%", "100%", "0", "1", "FFFFFF", "exactFit");
        //                chart.setDataXML(val);
        //                chart.render("chartdiv");
        //            }
        //        });
    };
    //加载
    this.searchClick();
}
